Hello and welcome to this lecture.
In this flick sure we will be creating the function for the app using JavaScript in this late show.
We will be using several features in Javascript will be first we'll be creating variables.
Variable is used to hold a single value we'll also be using a raise raise issues to hold or store multiple
values as one or two using functions functions is what will front will use the functions to actually
tell me what to do using the variables and the arrays.
So the first time we are going to do here is create a variable.
So this is our blank javascript file so to create a variable you type in the are lower case followed
by the name you want to call the variable.
In this case just give in.
Then let her do it.
You can call your variable whatever you like but there are set in mame's you can't use if you reference
the javascript documentation.
It will tell you.
Then I have given it a value because to a new date this here is have function in javascript which tells
you determine the function that will tell you the date set date function so the value the value of this
variable will be.
It was two new date whereby you see this back.
This is you.
He indicates that is a function.
This every function was have this person.
This is inside there is where you pass any values or arguments you want the function to use online to
have created another variable poured week day and give it a value each or two new Arri and here has
specified inside the parenthesis here.
This specify the irey will be 7 so there will be 7 values stored inside that rate.
So what I need to do now is specify those arrays.
So I have specified the array from line 3 to 9.
You can usually tell or identify an array with square brackets here where you have to see square brackets.
You'd know that you are looking at an array here as specified.
The value will be 7 4 and if you notice here the number and start from zero to six in that with an array
the very first horray is given a number of zero and then the second value.
So if I wanted to search or access the array with a value of zero bit excessive value called Sunday
or named Sunday.
Alright so the numbering starts with zero.
So here it is half past 7 so there's zero counts as one counts as a value OK to make up that 7 so that
would be 1 2 3 4 5 6 7.
So I have now specifying the values of this race.
Here I have created two more arrays.
Sorry two more variables on line 11 and 12.
The variable here.
Call it date number two dates two and the value is equal to a new date line 12.
This given a variable of weekday 2 to day value equals to an array.
And I want it to have 7 as well.
So I'm going to have to declare or specify the error here.
Like I have done here.
Okay so these are the arrays here.
You can tell again this start from zero to 6 which makes up 7.
So what this will be.
This will be the actual text that will be displayed a long day of the week for example if did deal of
the week is Sunday it would display tool chillax.
OK I need to modify it at time too.
Okay time to chillax.
All right so that's what these are just a text that will be D.
Played to correspond with each of the days of the week.
I have created some more variables here like 21 22 24 and 25.
So again you define a variable with the word.
Ah lower case have given it in name of n and a value of set two was two week day this week day three
and then there I have passed c d d d.
Here is from this variable D here.
Okay so up past did that value.
So I posted that value inside this irey Dot get D.
So this is a method of function that will get the day pass it into there.
All right here again.
Variable.
Giving a name to the value will be day 2 and dates to do again.
This is a name date two is the name of this variable here.
Okay.
And again we use this function to get the content of that tree and display it on line 24 to find another
variable called display.
We do.
The value was to document to get element by D.
This get element.
But Heidi this is use our past sit this idea of week day.
So if we look here we've got a night where our We've got the weekday e tool use.
See that's the week.
Then we use that week day this week.
Day here is from our hastier mail document document or get element a D So if I pop up to the hastier
mail here this is this is the idea is this looking for.
So rather than display this text here to replace it.
Take all that this I.D. and inject the code he replaces code with the javascript.
Okay so that's what it means.
It is replaced.
What's this.
This idea here by displaying the week day and this week here you will pick that from the irey again
here this phrase here is variable phrase equal documental get elemen by phrase again.
The phrase here is this.
Here is tool.
Replace the content here.
What is in the erry I have specified.
So so were you with the functions you have to get the variables defined first before you now create
the function to use those variables.
I have now created the function on line 29 to 34 so each time you grid of functionality was have apparently
sees and also curly braces.
This is the opening curly braces and this is the closing one right and in between the curly braces is
what the function will do what you want the function to do so to define a function you type in the word
function followed by the name of the function of this function.
What day is it.
So this is what I wanted a function to do.
I want to display the dot in a text.
So the weak display weak day which is this variable here it will display is variable dot in our text.
Okay this in text is the.
This year Miller's talking about an E tool set it.
Replace that with this value.
N the N here which is this variable here refers to a day week.
Okay so it will get the tool get the week day and replace it weeks.
The text from the hasty e-mail.
Okay.
That's what they mean again the same thing here.
It will pick up this phrase here it will reply as is for this.
In that text phrase with this end to hear the end to his day is a text that will go with the day of
the week.
Alright so the entire text me.
Pop over to our email in our text.
RIPLEY refers to these.
This is known as in Tex.
So what is in the US group.
Replace this and inject its own code from the arrays into the.
That's what it mean.
This in our text it's referring to these are rights.
So that's basically the javascript done so does make sure save it CLG file save or so.
This is our document a refresh this is should not show the correct day of the week which is Saturday
here in the UK is quite a refresh.
So today is Saturday and time to party time.
The party is.
The text would have come with a food fight or pull my javits group file.
Okay so today is Saturday which is day 6 and 6 here is gone.
Time to party so this is a text that goes with it.
So that's how this app works.
That's it.
We have finally finished our app that will determine what day of the week if it's.
Thank you so much.
This free to work on any web browser.
Take care.
All the best.